@extends('Layout/userbase')

@section('header-js')

  <!-- <link rel="shortcut icon" type="image/x-icon" href="{{ asset('icon/favicon.ico') }}"> -->
	<link rel="stylesheet" type="text/css" href="{{ asset('css/base.css') }}">
	<link rel="stylesheet" type="text/css" href="{{ asset('css/member.css') }}">
  <script type="text/javascript" src="{{ asset('js/jquery.js') }}"></script>

@endsection


@section('content')
        <div class="member-right fr">
            <div class="member-head">
                <div class="member-heels fl"><h2>我的收藏</h2></div>
            </div>
            <div class="member-switch clearfix">
                <ul id="H-table" class="H-table">
                    <li><a href="#">我的收藏的商品</a></li>
                </ul>
            </div>
            <div class="member-border">
               <div class="member-return H-over">
                   <div class="member-troll clearfix">
                       <div class="member-all fl"><a href="javascript:;" onClick="allxuan()"><b class="on"></b>全选</a></div>
                       <div class="member-all fl"><a href="javascript:;" onClick="allNoxuan()"><b class="yes"></b>全不选</a></div>
                       <div class="member-check clearfix fl"><a href="javascript:;" class="member-delete" onClick="delgood()">删除商品</a> </div>
                   </div>
                   <div class="time-border-list pc-search-list member-all1 clearfix">
                    @if(empty($goods))
                      <div class="pc-no">抱歉，您还没有收藏任何商品。请到商城逛逛吧！</div>
                    @else
                       <ul class="clearfix">
                        @foreach($goods as $v)
                          @if($v['status'] == 0)
                           <li class="limi">
                              <a href="{{route('goods.goodsdetail', ['id' => $v['id']])}}"> <div style="width:213px; height:213px"><img src="http://oydt3ttm3.bkt.clouddn.com/{{ $v['goods_pic'] }}" width="213"></div></a>
                              <p class="head-name"><a href="#">{{ $v['goods_name'] }}</a> </p>
                              <p><span class="price">￥{{ $v['price'] }}</span><span class="discount">降价通知</span></p>
                              <p><input type="checkbox" class="on" name="xxoo" value="{{ $v['id'] }}"></p>
                           </li>
                           @else
                           <li class="limi">
                              <a href="#"> <div style="width:213px; height:213px"><img src="http://oydt3ttm3.bkt.clouddn.com/{{ $v['goods_pic'] }}" width="213"></div></a>
                              <p class="head-name"><a href="#">{{ $v['goods_name'] }}</a> </p>
                              <p><span class="discount">该商品已下架</span></p>
                              <p><input type="checkbox" class="on" name="xxoo" value="{{ $v['id'] }}"></p>
                           </li>
                           @endif
                        @endforeach
                       </ul>
                    @endif
                   </div>
               </div>
            </div>
        </div>
</section>
<!-- 商城快讯 End -->

@endsection


@section('foot-js')

<script type="text/javascript">

//全选
function allxuan() {
  $('.limi input[name="xxoo"]').prop('checked', true);
}

//全不选
function allNoxuan()
{
  $('.limi input[name="xxoo"]').prop('checked', false);
}


//删除
function delgood() {
  $('.limi input[name="xxoo"]:checked').each(function(i) {
      var id = $(this).val();

      $.ajax({
        type: 'get',
        url: '{{ route("delgoodsstow") }}',
        data: 'id='+id,
        dataType: 'json',
        success:function (msg) {

          //删除失败
          if (msg.status == 404) {
            alert('删除失败');
            return false;
          }

          //删除成功
          if (msg.status == 200) {
            alert('删除成功');
            // console.log(that);
            location.reload();
          }
        },
      });
  });

}

 (function(a){
     a.fn.hoverClass=function(b){
         var a=this;
         a.each(function(c){
             a.eq(c).hover(function(){
                 $(this).addClass(b)
             },function(){
                 $(this).removeClass(b)
             })
         });
         return a
     };
 })(jQuery);

 $(function(){
     $("#pc-nav").hoverClass("current");
 });

</script>



@endsection
